import XLSX from "xlsx"
import FileSaver from "file-saver"
const outex = {
    methods:{
        exp(title='sheetjs'){
            let xlsxParam = { raw: true };//转换成excel时，使用原始的格式
            let wb = XLSX.utils.table_to_book(document.querySelector("#outTable"),xlsxParam);
            let wbout = XLSX.write(wb, {
                bookType: "xlsx",
                bookSST: true,
                type: "array"
            });
            try {
                FileSaver.saveAs(
                new Blob([wbout], { type: "application/octet-stream;charset=utf-8" }),
                `${title}.xlsx`
                );
            } catch (e) {
                if (typeof console !== "undefined") console.log(e, wbout);
            }
            return wbout;
        },
        exp1(title='sheetjs'){
          let xlsxParam = { raw: true };//转换成excel时，使用原始的格式
          let wb = XLSX.utils.table_to_book(document.querySelector("#outTable1"),xlsxParam);
          let wbout = XLSX.write(wb, {
              bookType: "xlsx",
              bookSST: true,
              type: "array"
          });
          try {
              FileSaver.saveAs(
              new Blob([wbout], { type: "application/octet-stream;charset=utf-8" }),
              `${title}.xlsx`
              );
          } catch (e) {
              if (typeof console !== "undefined") console.log(e, wbout);
          }
          return wbout;
      },
    }
}
export default outex